/*	Copyright (C) 2012  Claude Richard
 *
 *	Optimist Racing is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	Optimist Racing is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with Optimist Racing.  If not, see <http://www.gnu.org/licenses/>.
 */

//#include "Calculus.hpp"
//#include <sstream>
//
//
//NumberExpression::NumberExpression( double value )
//	: mValue( value )
//{
//}
//NumberExpression::~NumberExpression()
//{
//}
//double NumberExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	return mValue;
//}
//std::string NumberExpression::toString() const
//{
//	std::stringstream stre;
//	stre << mValue;
//	return stre.str();
//}
//
//
//AdditionExpression::AdditionExpression( int numExpressions, const Expression** expressions )
//	: mNumExpressions( numExpressions )
//{
//	mExpressions = new const Expression*[ numExpressions ];
//	for (int i=0; i<numExpressions; i++) {
//		mExpressions[i] = expressions[i];
//	}
//}
//AdditionExpression::~AdditionExpression()
//{
//	delete[] mExpressions;
//}
//double AdditionExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	double ret = 0;
//	for (int i=0; i<mNumExpressions; i++) {
//		ret += mExpressions[i]->Evaluate( numSpecifications, variables, values );
//	}
//	return ret;
//}
//std::string AdditionExpression::toString() const
//{
//	std::stringstream stre;
//	stre << "(" << mExpressions[0]->toString();
//	for (int i=1; i<mNumExpressions; i++) {
//		stre << " + " << mExpressions[i]->toString();
//	}
//	stre << ")";
//	return stre.str();
//}
//
//
//
//SubtractionExpression::SubtractionExpression( int numExpressions, const Expression** expressions )
//	: mNumExpressions( numExpressions )
//{
//	mExpressions = new const Expression*[ numExpressions ];
//	for (int i=0; i<numExpressions; i++) {
//		mExpressions[i] = expressions[i];
//	}
//}
//SubtractionExpression::~SubtractionExpression()
//{
//	delete[] mExpressions;
//}
//double SubtractionExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	double ret = mExpressions[0]->Evaluate( numSpecifications, variables, values );;
//	for (int i=1; i<mNumExpressions; i++) {
//		ret -= mExpressions[i]->Evaluate( numSpecifications, variables, values );
//	}
//	return ret;
//}
//std::string SubtractionExpression::toString() const
//{
//	std::stringstream stre;
//	stre << "(" << mExpressions[0]->toString();
//	for (int i=1; i<mNumExpressions; i++) {
//		stre << " - " << mExpressions[i]->toString();
//	}
//	stre << ")";
//	return stre.str();
//}
//
//
//MultiplicationExpression::MultiplicationExpression( int numExpressions, const Expression** expressions )
//	: mNumExpressions( numExpressions )
//{
//	mExpressions = new const Expression*[ numExpressions ];
//	for (int i=0; i<numExpressions; i++) {
//		mExpressions[i] = expressions[i];
//	}
//}
//MultiplicationExpression::~MultiplicationExpression()
//{
//	delete[] mExpressions;
//}
//double MultiplicationExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	double ret = mExpressions[0]->Evaluate( numSpecifications, variables, values );;
//	for (int i=1; i<mNumExpressions; i++) {
//		ret *= mExpressions[i]->Evaluate( numSpecifications, variables, values );
//	}
//	return ret;
//}
//std::string MultiplicationExpression::toString() const
//{
//	std::stringstream stre;
//	stre << "(" << mExpressions[0]->toString();
//	for (int i=1; i<mNumExpressions; i++) {
//		stre << " * " << mExpressions[i]->toString();
//	}
//	stre << ")";
//	return stre.str();
//}
//
//
//CosineExpression::CosineExpression( const Expression* expression )
//	: mExpression( expression )
//{
//}
//CosineExpression::~CosineExpression()
//{
//}
//double CosineExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	return cos( mExpression->Evaluate( numSpecifications, variables, values ) );
//}
//std::string CosineExpression::toString() const
//{
//	std::stringstream stre;
//	stre << "cos(" << mExpression->toString() << ")";
//	return stre.str();
//}
//
//
//SineExpression::SineExpression( const Expression* expression )
//	: mExpression( expression )
//{
//}
//SineExpression::~SineExpression()
//{
//}
//double SineExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	return sin( mExpression->Evaluate( numSpecifications, variables, values ) );
//}
//std::string SineExpression::toString() const
//{
//	std::stringstream stre;
//	stre << "sin(" << mExpression->toString() << ")";
//	return stre.str();
//}
//
//
//VariableExpression::VariableExpression( std::string name )
//	: mName( name )
//{
//}
//VariableExpression::~VariableExpression()
//{
//}
//double VariableExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	throw -1;
//}
//std::string VariableExpression::toString() const
//{
//	return mName;
//}
//
//
//UnknownFunctionExpression::UnknownFunctionExpression( const std::string& name, int numArguments, const Expression** arguments )
//	: mName( name )
//	, mNumArguments( numArguments )
//{
//	mArguments = new const Expression*[numArguments];
//	for (int i=0; i<numArguments; i++) {
//		mArguments[i] = arguments[i];
//	}
//}
//UnknownFunctionExpression::~UnknownFunctionExpression()
//{
//	delete[] mArguments;
//}
//double UnknownFunctionExpression::Evaluate( int numSpecifications, const Expression** variables, double* values ) const
//{
//	for (int i=0; i<numSpecifications; i++) {
//		if (variables[i]==this) {
//			return values[i];
//		}
//	}
//	throw -1;
//}
//std::string UnknownFunctionExpression::toString() const
//{
//	std::stringstream stre;
//	stre << mName << "(" << mArguments[0]->toString();
//	for (int i=1; i<mNumArguments; i++) {
//		stre << ", " << mArguments[i]->toString();
//	}
//	stre << ")";
//	return stre.str();
//}
//
//
////class DerivativeExpression : public Expression
////{
////private:
////	Expression*		mTopExpression;
////	int				mNumBottom;
////	Expression**	mBottomExpressions;
////	int*			mBottomExponents;
////};
////
////
////Expression& operator + ( const Expression& a, const Expression& b );